package com.course.model.convert;

import com.course.model.dto.ChapterDto;
import com.course.model.entity.Chapter;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @PROJECT_NAME: course
 * @DESCRIPTION: Business数据映射转换
 * @Author: 涂玄武
 * @DATE: 2021/4/9 10:59
 */
@Mapper
public interface BusinessConvert {

    BusinessConvert INSTANCE = Mappers.getMapper(BusinessConvert.class);

//    @Mappings(
//            //属性不对应时使用的直接
//            @Mapping(target = "courseId",source = "courseId")
//    )

    /**
     * Chapter转化为ChapterDto
     *
     * @param chapter
     * @return
     */
    ChapterDto chapterToDto(Chapter chapter);

    /**
     * ChapterDto转化为Chapter
     * @param chapterDto
     * @return
     */
    Chapter dtoToChapter(ChapterDto chapterDto);

    List<ChapterDto> chaptersToDtos(List<Chapter> chapterDtos);

}
